<template>
	<view class="show-loading-con" :class="{'mask': hasMask}" v-if="isShow">
		<view class="content">
			<view class="model">
				<image src="../../static/closebtn.png" mode="" @click="close()"></image>
			</view>
			<view class="code">
				<tki-qrcode v-if="ifShow" cid="qrcode2" ref="qrcode2" :val="val" :size="size" :onval="onval" :loadMake="loadMake"
				 :usingComponents="true" @result="qrR" />
			</view>
			<view class="model-btn-view">
				<wyb-button @click="copyval()" color="#10bcff" class="btn" width="200rpx" height="70rpx" type="filled">复制链接</wyb-button>
			</view>
		</view>
	</view>
</template>

<script>
	import { setClipboardData, getClipboardData } from '@/uni_modules/u-clipboard/js_sdk'
	import tkiQrcode from '@/components/tki-qrcode/tki-qrcode.vue'
	export default {
		props: {
			hasMask: {
				type: Boolean,
				default: false,
			},
			title: {
				type: String,
				default: '加载中',
			},
			val :{
				type: String,
				default: '加载中',
			}
		},
		data() {
			return {
				isShow: false,
				ifShow: true,
				size: 300, // 二维码大小
				unit: 'upx', // 单位
				background: '#b4e9e2', // 背景色
				foreground: '#309286', // 前景色
				pdground: '#32dbc6', // 角标色
				icon: '', // 二维码图标
				iconsize: 40, // 二维码图标大小
				lv: 3, // 二维码容错级别 ， 一般不用设置，默认就行
				onval: true, // val值变化时自动重新生成二维码
				loadMake: true, // 组件加载完成后自动生成二维码
				src: '' // 二维码生成后的图片地址或base64
			};
		},
		methods: {
			show() {
				this.isShow = true
			},
			hide() {
				this.isShow = false
			},
			close(){
				this.isShow = false
			},
			copyval(){
				setClipboardData(this.$props.val)
				uni.showToast({title:"复制成功",icon:'none'})
			}
		}
	}
</script>

<style lang="scss">
	.show-loading-con {
		height: 100vh;
		width: 100%;
		position: fixed;
		z-index: 999;
		top: 0;
		left: 0;

		.content {
			position: absolute;
			top: 40%;
			left: 50%;
			bottom: 0px;
			right: 0px;
			transform: translate(-50%, -50%);
			flex-direction: column;
			color: #fff;
			width: 15rem;
			height: 20rem;
			background: rgb(255, 255, 255);
			border-radius: .3rem;
			font-size: .9rem;

			image {
				width: 1.5rem;
				height: 1.5rem;
				margin: 10rpx;
				
			}

			.title {
				max-width: 5rem;
				overflow: hidden;
				white-space: nowrap;
				text-overflow: ellipsis;
			}


		}
	}

	.code {
		display: flex;
		justify-content: center;
		align-items: center;
		margin-top: 30rpx;
	}

	.model-btn-view {
		display: flex;
		justify-content: center;
		align-items: center;
		margin-top: 60rpx;
	}
	.model{
		display: flex;
		justify-content: flex-end;
	}
	.mask {
		background: rgba($color: #000000, $alpha: .3);
	}
</style>
